<template>
  <div class="login form">
    <div class="item">
      <span class="label">账号</span>
      <input type="text" class="input" placeholder="请输入账号" v-model="form.account" ></input>
    </div>
    <div class="item">
      <span class="label">密码</span>
      <input type="text" class="input" placeholder="请输入密码" v-model="form.password"></input>
    </div>
    <div class="tool">
      <Button class="button button-primary" @click="onLogin">登录</Button>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import http from '../utils/useHttp'
import { getStorage, setStorage } from '../utils/storage'
const emits = defineEmits(['login'])
const form =ref({
  account:"",
  password:""
})
const onLogin=()=>{
    http.post("/auth/login",form.value).then(res=>{
      console.log("res",res)
      setStorage("userInfo",JSON.stringify(res.data))
      emits("login",res)
    })
}
</script>
<style scoped lang="scss">
.login{
  padding: 15px 10px;
}
</style>
